#pragma once
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <msclr\marshal_cppstd.h>
#include "Teach.h"
#include "Stu.h"
#include "Off.h"
#include "Ren.h"
#include "AppOff.h"
#include "AppStu.h"
#include "AppTeach.h"
using namespace std;

namespace Project {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Applicant
	/// </summary>
	public ref class Applicant : public System::Windows::Forms::Form
	{
		int cnt;
	public:
		Applicant(void)
		{
			InitializeComponent();
			fill();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Applicant()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::TabControl^  tabControl1;
	protected:
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::ListBox^  listBox1;
	private: System::Windows::Forms::TabPage^  tabPage2;
	private: System::Windows::Forms::ListBox^  listBox2;
	private: System::Windows::Forms::TabPage^  tabPage3;
	private: System::Windows::Forms::ListBox^  listBox3;
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button3;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Applicant::typeid));
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->listBox2 = (gcnew System::Windows::Forms::ListBox());
			this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->listBox3 = (gcnew System::Windows::Forms::ListBox());
			this->tabControl1->SuspendLayout();
			this->tabPage1->SuspendLayout();
			this->tabPage2->SuspendLayout();
			this->tabPage3->SuspendLayout();
			this->SuspendLayout();
			// 
			// tabControl1
			// 
			this->tabControl1->Controls->Add(this->tabPage1);
			this->tabControl1->Controls->Add(this->tabPage2);
			this->tabControl1->Controls->Add(this->tabPage3);
			this->tabControl1->Location = System::Drawing::Point(0, 0);
			this->tabControl1->Name = L"tabControl1";
			this->tabControl1->SelectedIndex = 0;
			this->tabControl1->Size = System::Drawing::Size(665, 477);
			this->tabControl1->TabIndex = 0;
			// 
			// tabPage1
			// 
			this->tabPage1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage1.BackgroundImage")));
			this->tabPage1->Controls->Add(this->button1);
			this->tabPage1->Controls->Add(this->listBox1);
			this->tabPage1->Location = System::Drawing::Point(4, 22);
			this->tabPage1->Name = L"tabPage1";
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
			this->tabPage1->Size = System::Drawing::Size(657, 451);
			this->tabPage1->TabIndex = 0;
			this->tabPage1->Text = L"Students";
			this->tabPage1->UseVisualStyleBackColor = true;
			// 
			// button1
			// 
			this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button1->Location = System::Drawing::Point(568, 401);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(80, 35);
			this->button1->TabIndex = 12;
			this->button1->Text = L"Exit";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Applicant::button1_Click);
			// 
			// listBox1
			// 
			this->listBox1->BackColor = System::Drawing::Color::Silver;
			this->listBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox1->FormattingEnabled = true;
			this->listBox1->ItemHeight = 15;
			this->listBox1->Location = System::Drawing::Point(0, 1);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(648, 394);
			this->listBox1->TabIndex = 0;
			this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Applicant::listBox1_SelectedIndexChanged);
			// 
			// tabPage2
			// 
			this->tabPage2->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage2.BackgroundImage")));
			this->tabPage2->Controls->Add(this->button2);
			this->tabPage2->Controls->Add(this->listBox2);
			this->tabPage2->Location = System::Drawing::Point(4, 22);
			this->tabPage2->Name = L"tabPage2";
			this->tabPage2->Padding = System::Windows::Forms::Padding(3);
			this->tabPage2->Size = System::Drawing::Size(657, 451);
			this->tabPage2->TabIndex = 1;
			this->tabPage2->Text = L"Teachers";
			this->tabPage2->UseVisualStyleBackColor = true;
			// 
			// button2
			// 
			this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button2->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button2->Location = System::Drawing::Point(568, 396);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(80, 35);
			this->button2->TabIndex = 13;
			this->button2->Text = L"Exit";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Applicant::button2_Click);
			// 
			// listBox2
			// 
			this->listBox2->BackColor = System::Drawing::Color::Silver;
			this->listBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox2->FormattingEnabled = true;
			this->listBox2->ItemHeight = 15;
			this->listBox2->Location = System::Drawing::Point(0, 0);
			this->listBox2->Name = L"listBox2";
			this->listBox2->Size = System::Drawing::Size(656, 394);
			this->listBox2->TabIndex = 0;
			this->listBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Applicant::listBox2_SelectedIndexChanged);
			// 
			// tabPage3
			// 
			this->tabPage3->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"tabPage3.BackgroundImage")));
			this->tabPage3->Controls->Add(this->button3);
			this->tabPage3->Controls->Add(this->listBox3);
			this->tabPage3->Location = System::Drawing::Point(4, 22);
			this->tabPage3->Name = L"tabPage3";
			this->tabPage3->Padding = System::Windows::Forms::Padding(3);
			this->tabPage3->Size = System::Drawing::Size(657, 451);
			this->tabPage3->TabIndex = 2;
			this->tabPage3->Text = L"Officers";
			this->tabPage3->UseVisualStyleBackColor = true;
			// 
			// button3
			// 
			this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->button3->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->button3->Location = System::Drawing::Point(568, 400);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(80, 35);
			this->button3->TabIndex = 14;
			this->button3->Text = L"Exit";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &Applicant::button3_Click);
			// 
			// listBox3
			// 
			this->listBox3->BackColor = System::Drawing::Color::Silver;
			this->listBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(0)));
			this->listBox3->FormattingEnabled = true;
			this->listBox3->ItemHeight = 15;
			this->listBox3->Location = System::Drawing::Point(0, 0);
			this->listBox3->Name = L"listBox3";
			this->listBox3->Size = System::Drawing::Size(658, 394);
			this->listBox3->TabIndex = 0;
			// 
			// Applicant
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
			this->ClientSize = System::Drawing::Size(664, 475);
			this->Controls->Add(this->tabControl1);
			this->Name = L"Applicant";
			this->Text = L"Applicant";
			this->tabControl1->ResumeLayout(false);
			this->tabPage1->ResumeLayout(false);
			this->tabPage2->ResumeLayout(false);
			this->tabPage3->ResumeLayout(false);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {

	}
	private: void fill()
	{
				

				 AppTeach t[100];
				 ifstream file("TeachAppInfo.txt");
				 cnt = 0;
				 msclr::interop::marshal_context context;
				 while (file >> t[cnt].name){
					 t[cnt].name = gap(t[cnt].name);
					 String^  i1 = context.marshal_as<String^>(t[cnt].name);
					 file >> t[cnt].age;
					 t[cnt].age = gap(t[cnt].age);
					 String^  i2 = context.marshal_as<String^>(t[cnt].age);
					 file >> t[cnt].gender;
					 t[cnt].gender = gap(t[cnt].gender);
					 String^  i3 = context.marshal_as<String^>(t[cnt].gender);
					 file >> t[cnt].designation;
					 t[cnt].designation = gap(t[cnt].designation);
					 String^ i4= context.marshal_as<String^>(t[cnt].designation);
					 file >> t[cnt].qualification;
					 t[cnt].qualification = gap(t[cnt].qualification);
					 String^ i5= context.marshal_as<String^>(t[cnt].qualification);
					 file >> t[cnt].cgpa;
					 t[cnt].cgpa = gap(t[cnt].cgpa);
					 String^ i6= context.marshal_as<String^>(t[cnt].cgpa);
					 file >> t[cnt].experience;
					 String^ i7= context.marshal_as<String^>(t[cnt].experience);
					 listBox2->Items->Add(i1 +"|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7);
					 cnt++;
				 }
				 file.close();

				 AppStu s[100];
				 ifstream file1("StuAppInfo.txt");
				 cnt = 0;
				 while (file1 >> s[cnt].name){
					 s[cnt].name = gap(s[cnt].name);
					 String^  i1 = context.marshal_as<String^>(s[cnt].name);
					 file1 >> s[cnt].age;
					 s[cnt].age = gap(s[cnt].age);
					 String^  i2 = context.marshal_as<String^>(s[cnt].age);
					 file1 >> s[cnt].gender;
					 s[cnt].gender = gap(s[cnt].gender);
					 String^  i3 = context.marshal_as<String^>(s[cnt].gender);
					 file1 >> s[cnt].gpa;
					 s[cnt].gpa = gap(s[cnt].gpa);
					 String^  i4= context.marshal_as<String^>(s[cnt].gpa);
					 file1 >> s[cnt].guardian_name;
					 s[cnt].guardian_name = gap(s[cnt].guardian_name);
					 String^  i5 = context.marshal_as<String^>(s[cnt].guardian_name);
					 file1 >> s[cnt].contact_no;
					 s[cnt].contact_no= gap(s[cnt].contact_no);
					 String^  i6 = context.marshal_as<String^>(s[cnt].contact_no);
					 file1 >> s[cnt].address;
					 s[cnt].address = gap(s[cnt].address);
					 String^  i7 = context.marshal_as<String^>(s[cnt].address);
					 file1 >> s[cnt].clas;
					 String^  i8 = context.marshal_as<String^>(s[cnt].clas);
					 listBox1->Items->Add(i1 + "|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7 + "|" + i8);
					 cnt++;
				 }
				 file1.close();

				 AppOff o[100];
				 ifstream file2("OffAppInfo.txt");
				 cnt = 0;
				 while (file2 >> o[cnt].name){
					 o[cnt].name = gap(o[cnt].name);
					 String^  i1 = context.marshal_as<String^>(o[cnt].name);
					 file2 >> o[cnt].age;
					 o[cnt].age = gap(o[cnt].age);
					 String^  i2 = context.marshal_as<String^>(o[cnt].age);
					 file2 >> o[cnt].qualification;
					 o[cnt].qualification = gap(o[cnt].qualification);
					 String^  i3 = context.marshal_as<String^>(o[cnt].qualification);
					 file2 >> o[cnt].cgpa;
					 o[cnt].cgpa = gap(o[cnt].cgpa);
					 String^  i4 = context.marshal_as<String^>(o[cnt].cgpa);
					 file2 >> o[cnt].gender;
					 o[cnt].gender = gap(o[cnt].gender);
					 String^  i5 = context.marshal_as<String^>(o[cnt].gender);
					 file2 >> o[cnt].experience;
					 o[cnt].experience = gap(o[cnt].experience);
					 String^  i6 = context.marshal_as<String^>(o[cnt].experience);
					 file2 >> o[cnt].desired_post;
					 String^  i7 = context.marshal_as<String^>(o[cnt].desired_post);
					 listBox3->Items->Add(i1 + "|" + i2 + "|" + i3 + "|" + i4 + "|" + i5 + "|" + i6 + "|" + i7);
					 cnt++;
				 }
				 file2.close();

	}
private: System::Void listBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
}
		 private:string gap(string s)
		 {
					 int j = 20;
					 while (s.size() < j){
						 s +=" ";
					 }
					 return s;
		 }
};
}
